import 'package:flutter/material.dart';
import 'package:flutterhello/util/host_util.dart';
import 'package:get/get.dart';

class ActiviteCard extends StatelessWidget {
  var info;
  ActiviteCard({this.info});
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.only(left: 20, right: 20, top: 0, bottom: 20),
      child: getChild(),
    );
  }

  getChild() {
    return InkWell(
      child: Container(
        width: double.infinity,
        height: 100,
        child: Row(
          children: [
            Container(
              width: 150,
              height: 100,
              child: ClipRRect(
                borderRadius: BorderRadius.all(Radius.circular(10)),
                child: Image.network(
                  HostUtil.getHost() + info['images'][0],
                  fit: BoxFit.cover,
                ),
              ),
            ),
            SizedBox(
              width: 15,
            ),
            Expanded(
                child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Container(
                  width: double.infinity,
                  child: Text(
                    info['title'],
                    maxLines: 2,
                  ),
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Expanded(
                        child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        CircleAvatar(
                          radius: 10,
                          backgroundImage: NetworkImage(info['fromType'] ==
                                  'group'
                              ? HostUtil.getHost() + info['group'][0]['favicon']
                              : HostUtil.getHost() +
                                  info['user'][0]['favicon']),
                        ),
                        SizedBox(
                          width: 10,
                        ),
                        Text(
                          info['fromType'] == 'group'
                              ? info['group'][0]['groupname']
                              : info['user'][0]['username'],
                          style: TextStyle(fontSize: 12, color: Colors.black54),
                        )
                      ],
                    )),
                    Text(
                      info['createTime'].split(' ')[1],
                      style: TextStyle(fontSize: 12, color: Colors.black54),
                    )
                  ],
                )
              ],
            ))
          ],
        ),
      ),
      onTap: () {
        Get.toNamed('/act_detail', arguments: info);
      },
    );
  }
}
